/**
 * 
 */
package com.gr.staffpm.dhtmlx.datatypes;

import com.thoughtworks.xstream.converters.SingleValueConverter;


/**
 * @author Graham Rhodes 21 Jan 2011 13:06:35
 */
public class TaskConverter implements SingleValueConverter {

    /* (non-Javadoc)
     * @see com.thoughtworks.xstream.converters.ConverterMatcher#canConvert(java.lang.Class)
     */
    @Override
    @SuppressWarnings("rawtypes")
    public boolean canConvert(Class type) {
        return type.equals(Task.class);
    }

    /* (non-Javadoc)
     * @see com.thoughtworks.xstream.converters.SingleValueConverter#toString(java.lang.Object)
     */
    @Override
    public String toString(Object obj) {
        return String.valueOf(((Task) obj).getId());
    }

    /* (non-Javadoc)
     * @see com.thoughtworks.xstream.converters.SingleValueConverter#fromString(java.lang.String)
     */
    @Override
    public Object fromString(String str) {
        return new Task(Integer.parseInt(str));
    }

}
